package Test::YAVMM::Object;
use warnings;
use strict;

use Test::Most;
use base 'My::Test::Class';

sub serialization : Tests() {
    my $test = shift;

  SKIP: {
	my $class = $test->class;
	skip 'base class' if ($class eq 'YAVMM::Object');

	# init object
	my $obj = $test->build_test_object;

	can_ok $obj, 'pack';
	can_ok $obj, 'unpack';

	my $packed = $obj->pack;
	my $unpacked_obj = $class->unpack($packed);

	for my $attr ($class->meta->get_all_attributes) {
	    my $name = $attr->name;
	    is $obj->$name, $unpacked_obj->$name,
		"... $name matches";
	}

	can_ok $obj, 'freeze';
	can_ok $obj, 'thaw';

	my $frozen = $obj->freeze;
	my $thawed_obj = $class->thaw($frozen);

	for my $attr ($class->meta->get_all_attributes) {
	    my $name = $attr->name;
	    is $obj->$name, $thawed_obj->$name,
		"... $name matches";
	}

    }
}

1;
